import { PROMOTION_MAP, CHANNEL_PROMOTION_MAP } from 'constants/index';

interface IOption {
  value: number | string;
  label: string;
}

// 合同状态枚举
export const CONTRACT_STATUS = {
  FAIL: 0,
  AUDIT_PENDING: 1,
  EXEC_PENDING: 2,
  EXECUTING: 3,
  FINISH: 4,
};

export const CONTRACT_STATUS_OPTIONS: Array<IOption> = [
  { value: CONTRACT_STATUS.FAIL, label: '审核失败' },
  { value: CONTRACT_STATUS.AUDIT_PENDING, label: '待审核' },
  { value: CONTRACT_STATUS.EXEC_PENDING, label: '待履行' },
  { value: CONTRACT_STATUS.EXECUTING, label: '审核成功' },
  { value: CONTRACT_STATUS.FINISH, label: '已完成' },
];

export const USER_TYPE_OPTIONS: Array<IOption> = [
  { value: 'user', label: '普通用户' },
  { value: 'vip', label: '会员用户' },
  { value: 'staff', label: '内部人员' },
];

// 合同类型枚举
export const CONTRACT_TYPES = {
  MAIN: 0,
  SUB: 1,
  SUPPLEMENT: 2,
};

export const CONTRACT_TYPE_OPTIONS: Array<IOption> = [
  { value: CONTRACT_TYPES.MAIN, label: '主合同' },
  { value: CONTRACT_TYPES.SUB, label: '子合同' },
  { value: CONTRACT_TYPES.SUPPLEMENT, label: '补充合同' },
];

export const USER_STATUS_OPTIONS: Array<IOption> = [
  { value: 1, label: '正常' },
  { value: 2, label: '禁用' },
  { value: 3, label: '未激活' },
];

export const SOURCE_OPTIONS: Array<IOption> = [
  {
    label: '官网',
    value: 1,
  },
  {
    label: '后台',
    value: 2,
  },
  ...PROMOTION_MAP,
  ...CHANNEL_PROMOTION_MAP,
];

export const handleSource = (value: string, setUpload: any) => {
  if (PROMOTION_MAP.some((item) => item.value === value)) {
    setUpload((pre) => ({
      ...pre,
      qudao: true,
      tuiguang: false,
    }));
  } else if (CHANNEL_PROMOTION_MAP.some((item) => item.value === value)) {
    setUpload((pre) => ({
      ...pre,
      tuiguang: true,
      qudao: false,
    }));
  } else {
    setUpload((pre) => ({
      ...pre,
      qudao: true,
      tuiguang: true,
    }));
  }
};
